<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="/spring"%>
<%@page import="java.util.List" %>
<%@page import="pt.mleiria.vo.GuestbookVO" %>
<%
 java.util.Map<String, String> menuMap = (java.util.Map<String, String>)request.getSession().getAttribute("menuMap");
 String nome = menuMap.get("nome");
 String comentario = menuMap.get("comentario");
 String obrigado = menuMap.get("obrigado");
 %>
<head>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/estilos_app.css" type="text/css"> 
   	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/cssverticalmenu.css" />
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/cssverticalmenu.js"></script>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style>
html, body {
margin:0;
padding:0;
}

#wrapper {
width:100%;
float: right; /* swap */
margin-left:-180px; /* swap */
}

#content {
margin-left: 270px; /* swap */
background: #ddd;
} 

#nav {
width: 180px;
float: right;
}

</style>

</head>
<body>
<div class="transparent" id="divIntro">
	<FORM method="post">
			<table border="0" align="center" cellpadding="2" cellspacing="0" width="600px">
			
			<%
			List<GuestbookVO> comments = (List<GuestbookVO>)request.getSession().getAttribute("comments");
			for(GuestbookVO gb : comments){
				%><tr><td><%
				out.println(gb.getName() + "    " + gb.getRegDate());%><br><%
				out.println(gb.getComment());
				%></td></tr><%
			}
			%>
			<tr>
				<td>
					<%
					if(request.getSession().getAttribute("obrigado") != null){
						boolean isObrigado = (Boolean)request.getSession().getAttribute("obrigado");
						if(isObrigado == true){
							out.println(obrigado);
							isObrigado = false;	
							request.getSession().setAttribute("obrigado", null); 
						}
					}
					%>
				</td>
			</tr>
			<tr>
				<td>
					<%=nome%><br>
					<spring:bind path="guestbookCommand.name">
			        	<input name="name" value="<c:out value="${status.value}"/>" type="text"/>
			        </spring:bind>
			   </td>
			</tr>
			<tr>
			   <td>
			        <%=comentario%><br>
			        <spring:bind path="guestbookCommand.comment">
			        	<textarea rows="10" cols="50" name="comment" value="<c:out value="${status.value}"/>"></textarea>
			        </spring:bind>
				</td>
			</tr>
			<tr>
		        <td width="400" align="left">
		        	<input name="submit" type="submit" class="button_link" value="Submit"/>
		      </tr>
			</table>
		</FORM>
</div>
<div id="wrapper">
<div id="content">
<img src="<%=request.getContextPath()%>/images/guestbook.jpg" height="700px"></img>

</div>
</div>

<div id="nav">
<img src="<%=request.getContextPath()%>/images/topLeft.jpg"></img><p></p><p></p>
<%@ include file="include.jsp"%>
</div>

</body>
</html> 